<template>
    <div>
        <div class="container">
            <div class="handle-box">
                <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
                    <el-option key="1" label="市场查获" value="市场查获"></el-option>
                    <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
                    <el-option key="3" label="上级交办" value="上级交办"></el-option>
                </el-select>
                <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
                    <el-option key="1" label="一般案件" value="一般案件"></el-option>
                    <el-option key="2" label="简易案件" value="简易案件"></el-option>
                </el-select>
                <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
                <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
            </div>
            <el-table :data="tableList" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <!--        <el-table-column prop="case_id" label="案件号" width="100" align="center"></el-table-column>-->
                <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
                <el-table-column prop="case_number" label="立案编号" width="200" align="center"></el-table-column>
                <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
                <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
                <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
                <el-table-column label="听证状态" align="center" width="180">
                    <template #default="scope">
                        <div v-if="scope.row.tcs_note_id === '听证已开始' ">
                            <el-tag :type=" 'danger'">听证已开始</el-tag>
                        </div>
                        <div v-if="scope.row.tcs_note_id === '听证告知书已完成' ">
                            <el-tag :type=" 'danger'">听证告知书已完成</el-tag>
                        </div>

                        <div v-if="scope.row.tcs_note_id === '已完成' ||
                                scope.row.tcs_note_id === '无证经营公示已完成' ||
                                scope.row.tcs_note_id ==='案件处理审批已开始'||
                                scope.row.tcs_note_id ==='听证已完成'||
                                scope.row.tcs_note_id ==='案件处理审批已完成'||
                                scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
                                scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书已完成'||
                                scope.row.tcs_note_id ==='行政罚款收据上传完成'||
                                scope.row.tcs_note_id ==='行政罚款收据已完成'||
                                scope.row.tcs_note_id ==='结案报告表已完成'">
                            <el-tag :type=" 'success'">已完成 </el-tag>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="下一步操作" width="350" align="center">
                    <template #default="scope">
                        <div v-if="scope.row.tcs_note_id === '听证已开始' ">
                            <el-button text :icon="Edit" class="blue" @click="hearing_notice_table(scope.row)" >
                                听证告知书填写
                            </el-button>

                        </div>
                        <div v-if="scope.row.tcs_note_id === '听证告知书已完成' ">
                            <el-button text :icon="Edit" class="blue" @click="hearing_arrive_document_tabel(scope.row)" >
                                送达文书填写
                            </el-button>
                        </div>

                        <div v-if="scope.row.tcs_note_id === '已完成' ||
                                scope.row.tcs_note_id === '无证经营公示已完成' ||
                                scope.row.tcs_note_id ==='案件处理审批已开始'||
                                scope.row.tcs_note_id ==='听证已完成'||
                                scope.row.tcs_note_id ==='案件处理审批已完成'||
                                scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
                                scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书已完成'||
                                scope.row.tcs_note_id ==='行政罚款收据上传完成'||
                                scope.row.tcs_note_id ==='行政罚款收据已完成'||
                                scope.row.tcs_note_id ==='结案报告表已完成'">
                            <el-button text :icon="Edit" class="blue" @click="hearing_notice_browse(scope.row)" >
                                查看听证告知书
                            </el-button>
                            <el-button text :icon="Edit" class="blue" @click="hearing_arrive_document_browse(scope.row)" >
                                查看送达回证
                            </el-button>

                        </div>


                    </template>
                </el-table-column>
            </el-table>
          <div class="pagination">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page="query.pageIndex"
                :page-size="query.pageSize"
                :total="pageTotal"
                @current-change="handlePageChange"
            ></el-pagination>
          </div>
        </div>

        <el-dialog title="送达文书填写" v-model="Hearing_arrive_document_Visible" width="45%">
            <el-form ref="form"  :model="form" label-width="100px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="送达文书名称">
                            <el-input v-model="hearing_arrive_document_data.arrive_document_name" :disabled="true" ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="文书文号">
                            <el-input v-model="hearing_arrive_document_data.arrive_number" :disabled="true"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="受送达人">
                            <el-input  v-model="hearing_arrive_document_data.addressee"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达方式">
                            <el-input  v-model="hearing_arrive_document_data.service_mode"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="hearing_arrive_document_data.arrive_person1" @change="get_interrogator_clause_opinion(create_case.interrogator)" clearable filterable placeholder="请选择">
                                                                <el-option
                                                                        v-for="(item,index) in interrogator_Data"
                                                                        :key='index'
                                                                        :label='item.staff_name'
                                                                        :value='item.staff_id'
                                                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="hearing_arrive_document_data.arrive_person2"  @change="get_interrogator_clause_opinion(create_case.interrogator)" clearable filterable placeholder="请选择">
                                                                <el-option
                                                                        v-for="(item,index) in interrogator_Data"
                                                                        :key='index'
                                                                        :label='item.staff_name'
                                                                        :value='item.staff_id'
                                                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-form-item label="送达地点">
                    <el-input v-model="hearing_arrive_document_data.arrive_place"  type="textarea" rows="2"></el-input>
                </el-form-item>
                <el-form-item label="收件人签章">
                    <el-input v-model="hearing_arrive_document_data.receipt_signature" type="textarea" rows="2"></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="12">
                    <el-form-item label="签收日期">
                        <el-date-picker v-model="hearing_arrive_document_data.receipt_time"   type="datetime" placeholder="选择签收日期" value-format="YYYY-MM-DD HH:mm:ss">
                        </el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达日期">
                            <el-date-picker v-model="hearing_arrive_document_data.arrive_time"   type="datetime" placeholder="选择送达日期" value-format="YYYY-MM-DD HH:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-form-item label="代收理由">
                    <el-input type="textarea" rows="2" v-model="hearing_arrive_document_data.subsitute_reason"></el-input>
                </el-form-item>
                <el-form-item label="见证人签章">
                    <el-input type="textarea" rows="2" v-model="hearing_arrive_document_data.witness_signature"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input type="textarea" rows="2" v-model="hearing_arrive_document_data.remarks" ></el-input>
                </el-form-item>

            </el-form>

            <template #footer>
              <span class="dialog-footer">
                  <el-button @click="Hearing_arrive_document_Visible = false">取 消</el-button>
        <el-button type="primary" @click="certain_arrive_document">确 定</el-button>
              </span>
            </template>
        </el-dialog>


        <el-dialog title="听证告知书填写" v-model="Hearing_notice_Visible" width="45%">
            <el-form ref="form"  :model="form" label-width="100px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="当事人">
                            <el-input v-model="hearing_notice_data_storage.tir_person"  :disabled="true" ></el-input>
                        </el-form-item>

                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="时间">
                            <el-date-picker  v-model="hearing_notice_data_storage.hearing_time"  type="datetime" placeholder="选择时间" value-format="YYYY-MM-DD HH:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                    <el-form-item label="违法行为">
                        <el-input v-model="hearing_notice_data_storage.illegal_behavior" :disabled="true"></el-input>
                    </el-form-item>
                <el-form-item label="违反法律">
                    <el-input v-model="hearing_notice_data_storage.violate_law"  type="textarea" rows="4"></el-input>
                </el-form-item>
                <el-form-item label="处罚决定">
                    <el-input v-model="hearing_notice_data_storage.penalty_decision" type="textarea" rows="4"></el-input>
                </el-form-item>
                <el-form-item label="处罚依据">
                    <el-input v-model="hearing_notice_data_storage.punish_basis" type="textarea" rows="4"></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="承办人">
                            <el-select v-model="hearing_notice_data_storage.undertaker1" @change="get_interrogator_clause_opinion(create_case.interrogator)" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="承办人">
                            <el-select v-model="hearing_notice_data_storage.undertaker2"  @change="get_interrogator_clause_opinion(create_case.interrogator)" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>

                <el-form-item label="烟草局地址">
                    <el-input v-model="hearing_notice_data_storage.bureau_address" ></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="邮编">
                            <el-input  v-model="hearing_notice_data_storage.postal_code"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="联系电话">
                            <el-input  v-model="hearing_notice_data_storage.telephone_number"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                  <el-button @click="Hearing_notice_Visible = false">取 消</el-button>
        <el-button type="primary" @click="certain_hearing_notice">确 定</el-button>
              </span>
            </template>
        </el-dialog>


        <!--    听证告知书送达回证-->
        <el-dialog title="" v-model="View_Hearing_arrive_document_Visible" width="38%" >
            <html>
            <head>
                <title>送&nbsp;&nbsp;&nbsp;达&nbsp;&nbsp;&nbsp;回&nbsp;&nbsp;&nbsp;证</title>
            </head>
            <body>
            <h1 align="center">
                福建省闽侯县烟草专卖局
            </h1>
            <h1 align="center">
                送达回证
            </h1>
            <div align="center">
            <font size="3">
                侯烟送[{{hearing_arrive_document_data.year}}]第{{hearing_arrive_document_data.case_number}}号
            </font>
            </div>
            <table border="1" style="border-collapse: collapse;" width="100%">
                <tr>
                    <th height="50" width="14%">送达文书名称</th>
                    <th  width="36%" >{{hearing_arrive_document_data.arrive_document_name}}</th>
                    <th width="14%">送达文书文号</th>
                    <th width="36%">{{hearing_arrive_document_data.arrive_number}}</th>
                </tr>
                <tr>
                    <th height="35">受送达人</th>
                    <th colspan="3">{{hearing_arrive_document_data.addressee}}</th>
                </tr>
                <tr>
                    <th height="50">送达地点</th>
                    <th colspan="3">{{hearing_arrive_document_data.arrive_place}}</th>
                </tr>
                <tr>
                    <th height="35">送达方式</th>
                    <th colspan="3">{{hearing_arrive_document_data.service_mode}}</th>
                </tr>
                <tr>
                    <th height="60">收件人签名或盖章</th>
                    <th colspan="3">{{hearing_arrive_document_data.receipt_signature}}</th>
                </tr>
                <tr>
                    <th height="45">签收日期</th>
                    <th colspan="3">{{hearing_arrive_document_data.year1}}&nbsp;年&nbsp;{{hearing_arrive_document_data.month1}}&nbsp;月&nbsp;{{hearing_arrive_document_data.day1}}&nbsp;日&nbsp;
                        {{hearing_arrive_document_data.hour1}}&nbsp;时&nbsp;{{hearing_arrive_document_data.min1}}&nbsp;分</th>
                </tr>
                <tr >
                    <th height="55">代收人注明代收理由</th>
                    <th colspan="3">{{hearing_arrive_document_data.subsitute_reason}}</th>
                </tr>
                <tr>
                    <th height="35">见证人签名或盖章</th>
                    <th colspan="3">{{hearing_arrive_document_data.witness_signature}}</th>
                </tr>
                <tr>
                    <th height="35">送达人签名</th>
                    <th colspan="3">{{hearing_arrive_document_data.staff_name1}}&nbsp;:&nbsp;{{hearing_arrive_document_data.staff_license_no1}}&nbsp;
                        {{hearing_arrive_document_data.staff_name2}}&nbsp;:&nbsp;{{hearing_arrive_document_data.staff_license_no2}}</th>
                </tr>
                <tr>
                    <th height="35">送达日期</th>
                    <th colspan="3">{{hearing_arrive_document_data.year2}}&nbsp;年&nbsp;{{hearing_arrive_document_data.month2}}&nbsp;月&nbsp;{{hearing_arrive_document_data.day2}}&nbsp;日&nbsp;
                        {{hearing_arrive_document_data.hour2}}&nbsp;时&nbsp;{{hearing_arrive_document_data.min2}}&nbsp;分</th>
                </tr>
                <tr>
                    <th height="70">备&nbsp;&nbsp;&nbsp;&nbsp;注</th>
                    <th colspan="3">{{hearing_arrive_document_data.remarks}}</th>
                </tr>


            </table>
            </body>
            </html>
            <template #footer>
				<span class="dialog-footer">
                  <el-button @click="View_Hearing_arrive_document_Visible=false" >取 消</el-button>
          <el-button type="primary" :icon="Printer" @click="hearing_arrive_document_print">打 印</el-button>
				</span>
            </template>
        </el-dialog>


        <!--听证告知书预览-->
        <el-dialog title="" v-model="Hearing_notice_Borwse_Visible" width="34%">
            <html>
            <head>
                <title>听证告知书</title>
            </head>
            <body>
            <h1 align="center">
                福建省闽侯县烟草专卖局
            </h1>
            <h1 align="center">
                听证告知书
            </h1>
            <div align="center">
                <font size="3">侯烟听告[{{hearing_notice_data_storage.year}}]第{{hearing_notice_data_storage.case_number}}号</font>
            </div>
            <div >

                <font size="3">
                    {{hearing_notice_data_storage.tir_person}}：
                </font>

            </div>
            <div >

                <font size="3">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;你于{{hearing_notice_data_storage.year}}年{{hearing_notice_data_storage.month}}月{{hearing_notice_data_storage.day}}日，因{{hearing_notice_data_storage.illegal_behavior}}行为，违反了{{hearing_notice_data_storage.violate_law}}，构成了{{hearing_notice_data_storage.illegal_behavior}}的事实。根据《中华人民共和国行政处罚法》第二十八条规定，现责令当事人改正上述行为。
                    并根据{{hearing_notice_data_storage.punish_basis}}的规定，决定处罚如下:
                </font>

            </div>
            <div >

                <font size="3">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;对当事人{{hearing_notice_data_storage.tir_person}}{{hearing_notice_data_storage.illegal_behavior}}的违法行为，{{hearing_notice_data_storage.penalty_decision}}。
                </font>

            </div>
            <div >

                <font size="3">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;根据《中华人民共和国行政处罚法》第六十三条、第六十四条和《烟草专卖行政处罚程序规定》第四十四条第一款第（二）项的规定，当事人有要求举行听证的权利。如你要求举行听证，应该在收到本告知书后五日内向本局提出申请。逾期未提出的，视为放弃要求举行听证的权利。
                </font>

            </div>
            <div>
                <strong>
                    <font size="3">
                        本局地址：{{hearing_notice_data_storage.bureau_address}}
                    </font>
                </strong>
            </div>
            <div>
                <strong>
                    <font size="3">
                        邮编：{{hearing_notice_data_storage.postal_code}}
                    </font>
                </strong>
            </div>
            <div>
                <strong>
                    <font size="3">
                        联系电话：{{hearing_notice_data_storage.telephone_number}}
                    </font>
                </strong>
            </div>
            <div>
                <strong>
                    <font size="3">
                        承办人（签名）：<b><u>{{hearing_notice_data_storage.undertaker1_name}}&nbsp;&nbsp;&nbsp;执法证号：{{hearing_notice_data_storage.staff_license_no1}}</u></b>_______________
                    </font>
                </strong>

            </div>
            <div align="right">
                <strong>
                    <font size="3">
                        <b><u>{{hearing_notice_data_storage.undertaker2_name}}&nbsp;&nbsp;&nbsp;执法证号：{{hearing_notice_data_storage.staff_license_no2}}</u></b>________________
                    </font>
                </strong>
            </div>
            <div align="right">
                <strong>
                    <font size="3">
                        福建省闽侯县烟草专卖局
                    </font>
                </strong>
                <br>
                <strong>
                    <font size="3">
                        （印&nbsp;&nbsp;章）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </font>
                </strong>
            </div>

            <div align="right">
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{hearing_notice_data_storage.year1}}&nbsp;年&nbsp;{{hearing_notice_data_storage.month1}}&nbsp;月&nbsp;{{hearing_notice_data_storage.day1}}&nbsp;日
                    </font>
                </strong>
            </div>
            <div >
                <strong>
                    <font size="3">
                        当事人意见及签名：_____________________________________
                    </font>
                </strong>
            </div>

            </body>
            </html>
            <template #footer>
				<span class="dialog-footer">
					<el-button @click="Hearing_notice_Borwse_Visible = false">取 消</el-button>
          <el-button :icon="Printer" type="primary" @click="create_hearing_notice_word">打 印</el-button>
				</span>
            </template>
        </el-dialog>



<!--        <el-dialog title="听证告知书内容确认" v-model="Hearing_notice_content_Visible" width="45%">-->
<!--            <el-form ref="form"  :model="form" label-width="100px">-->
<!--                <el-row>-->
<!--                    <el-col :span="12">-->
<!--                        <el-form-item label="当事人">-->
<!--                            <el-input   :disabled="true" ></el-input>-->
<!--                        </el-form-item>-->

<!--                    </el-col>-->
<!--                </el-row>-->

<!--                <el-form-item label="告知书内容">-->
<!--                    <el-input   type="textarea" rows="20"></el-input>-->
<!--                </el-form-item>-->


<!--            </el-form>-->

<!--            <template #footer>-->
<!--              <span class="dialog-footer">-->
<!--                  <el-button @click="Hearing_notice_Visible = false">取 消</el-button>-->
<!--        <el-button type="primary" @click="certain_hearing_notice">确 定</el-button>-->
<!--              </span>-->
<!--            </template>-->
<!--        </el-dialog>-->








    </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete, Edit, Search, Plus,Printer } from '@element-plus/icons-vue';
import {
    case_evi_Create,
    case_evi_Views,
    case_legal_Create,
    ciga_evudence_Create,
    end_record_data,
    evi_Views,
    fetchData_case,
    fetchData_case_Create,
    fetchData_case_update,
    fetchData_legal_clause,
    fetchData_mer,
    fetchData_s_mongodb_evidence_Cre,
    fetchData_s_mongodb_evidence_Views,
    fetchData_tobacco,
    fetchData_user,
    illegal_record_data,
    illegal_record_Search,
    mer_Create,
    mer_search_api,
    review_price_data,
    staff_evidence_create,
    staff_evidence_data,
    end_record_show,
    record_inquiry_show,
    record_inquiry_print,
    case_evidence_Views,
    case_evidence_Edit,
    question_answer_clause_delete,
    price_review_clause_delete,
    fetchData_user_Edit,
    fetchData_price_Edit,
    hearing_arrive_document, fetchData_interrogator_clause, fetchData_inquiry_record_Confirm, fetchData_arrive_document_Confirm, hearing_arrive_document_print_data, hearing_notice_data, fetchData_hearing_notice_Confirm, hearing_notice_browse_data
} from '../api/index';
import {
    export_word_13,export_word_12
} from './table_inquiry.vue'

//案件表数据
interface TableItem {
    case_id:number,
    date_of_filing:string,
    date_of_closing:string,
    date_of_archive:string,
    case_source:string,
    case_number:string,
    archive_person:string,
    case_update_time:string,
    ase_type:string,
    case_remark:string,
    tcs_note_id:string,
    ciga_flag:string,
    ciga_num_flag:string,
    mer_flag:string,
}

//案件暂存数据
const create_case = reactive({
    case_id:0,
    staff_evi_id:0,
    staff_id:0,
    staff_evi_send_per:'',
    staff_evi_check_per1:'',
    staff_evi_check_per2:'',
    staff_evi_send_time:'',
    staff_evi_send_unit:'',
    staff_evi_send_result:'',
    staff_evi_rec_address:'',
    staff_evi_status:'',
    staff_evi_per_note:'',
    mer_flag:'',
    ciga_num_flag:'',
    ciga_flag:'',
    test:[],
    img_data:'',
    standard:'',
    tir_id:0,
    tlc_id:0,
    illegal_behavior:'',
    evi_id_number:'',
    evi_id:'',
    date_of_filing:'',
    date_of_closing:'',
    date_of_archive:'',
    case_source:'',
    case_number:'',
    archive_person:'',
    case_update_time:'',
    case_type:'',
    case_remark:'',
    mer_id:0,
    tcs_note:'',
    cs_note:'',
    tce_time:'',
    tce_number:0,
    tce_amount:0,
    tce_remark:'',
    tce_address:'福建省福州市闽侯县烟草专卖局',
    evi_number:0,//数量(条)
    ciga_variety:'',//品种
    barcode:'',//条形码
    ciga_model:'',//规格型号
    ciga_price:0,//单价
    inkjet:'',//
    mer_format:'',
    mer_address:'',
    mer_person:'',
    mer_record:'',
    date_of_record:'',
    date_of_effect:'',
    date_of_issue:'',
    mer_hometown:'',
    mer_id_number:'',
    mer_tel:'',
    business_licence_code:'',
    licence_state:'',
    storage_address:'',
    retail_licence_code:'',
    category:'',
    area_id:0,
    mer_zip_code:0,
    mer_name:'',
    remark:'',
});
//获取商户数据用作选项框
interface mer_data {
    mer_id: number,
    mer_format: string,
    mer_address: string,
    mer_person: string,
    mer_record: string,
    date_of_record: string,
    date_of_effect: string,
    date_of_issue: string,
    mer_hometown: string,
    mer_id_number: string,
    mer_tel: string,
    business_licence_code: string,
    licence_state: string,
    storage_address: string,
    retail_licence_code: string,
    category: string,
    area_id: number,
    mer_zip_code: number,
    mer_name: string,
}
const mer_Data = ref<mer_data[]>([]);
const get_mer_opinion = (mer_name:string='',licence_state:string='',mer_person:string='' ,mer_id:number,business_licence_code:string='') =>{
    fetchData_mer(mer_name,licence_state,mer_person,mer_id,business_licence_code).then(res =>{
        mer_Data.value = res.data.data;
    })
}
get_mer_opinion();
//获取执法人员数据作为选择框
interface staff_data{
    staff_id:number,
    staff_name:string,
    staff_gender:string,
    staff_birthday:string,
    staff_ethnicity:string,
    staff_edu_bg:string,
    staff_email:string,
    field_staff_identity_card:string,
    staff_hometown:string,
    staff_degree:string,
    staff_political_status:string,
    staff_post:string,
    staff_account_no:string,
    staff_account_pwd:string,
    staff_starting_time:string,
    staff_authorized:string,
    staff_phone:string,
    staff_tel:string,
    staff_e_sign:string,
    staff_small_number:string,
    staff_license_no:string,
    staff_now_work_degree:string,
    staff_now_evaluate_degree:string,
}
const staff_Data = ref<staff_data[]>([]);
const get_staff_opinion1 = () =>{
    fetchData_user('','','').then(res=>{
        staff_Data.value = res.data.data;
    })
}
get_staff_opinion1();

//获取案由信息数据用作选项框
interface illegal_data {
    tlc_id:number,
    illegal_behavior:string,
    standard:string,
    penalty_range:string,
    statutory_penalty:string,
    grade:string,
    remark:string,
}
const illegal_Data = ref<illegal_data[]>([]);
const get_legal_clause_opinion = (illegal_behavior:string='',standard:string='' ,grade:string='',tlc_id:number) =>{
    fetchData_legal_clause(illegal_behavior, standard,grade,tlc_id).then(res =>{
        illegal_Data.value = res.data.data;
    })
}
get_legal_clause_opinion();


//视图/

const Ratification_Visible = ref(false);                              //批准书视图
const Ratification_Edit_Visible = ref(false);                         //批准书修改视图
const Advice_note_Visible = ref(false);                               //通知书视图
const Advice_note_Views_Visible = ref(false);                         //查看通知书视图
const Price_list_Visible = ref(false);                                //核价表视图
const Price_list_Browse_Visible = ref(false);                                //核价表视图
const Hearing_notice_content_Visible=ref(false);                             //听证告知书内容确认视图
const Hearing_notice_Visible=ref(false);                                    //听证告知书
const Hearing_arrive_document_Visible=ref(false);                           //听证告知书送达文书视图
const View_Hearing_arrive_document_Visible=ref(false);                //听证告知书送达回文
const Hearing_notice_Borwse_Visible=ref(false);                            //听证告知书预览



//通过案件号查询所有证据先行保存通知书
interface Evidence_case_data {
    evi_id:number,
    case_id:number,//案件号
    evi_id_number:string,
    evi_number:number,
    tce_time_year:string,//案件时间
    tce_time_month:string,
    tce_time_day:string,
    tce_type_number:string,
    tce_number:string,
    tce_amount:number,
    tce_remark:string,
    tce_address:string,
    single_total:string,
}
const evidence_case_Data= ref<Evidence_case_data[]>([]);
//核价表信息显示
const get_review_price_Data=(case_id:number)=>{
    evi_Views("",case_id).then(res=>{
        evidence_ciga_Data.value = res.data.data;
    })
}


//听证告知书暂存记录
const hearing_notice_data_storage=reactive({
    illegal_behavior:'',//违法行为
    tir_person:'',
    violate_law:'',//违反法律
    penalty_decision:'',//处罚决定
    undertaker1:'',//承办人1
    undertaker2:'',//承办人2
    hearing_time:'',
    hearing_notice_content:'',
    bureau_address:'福建省福州市闽侯县甘蔗街道滨城大道69号闽商财富中心一楼',
    postal_code:'350100',
    telephone_number:'0591-62080093',
    undertaker1_name:'',
    undertaker2_name:'',
    staff_license_no1:'',
    staff_license_no2:'',
    year:'',
    month:'',
    day:'',
    year1:'',
    month1:'',
    day1:'',
    case_number:'',
    punish_basis:'',
})

const get_hearing_notice_browse_data=(row:any)=>{
    hearing_notice_browse_data(row.case_id).then(res=>{
        hearing_notice_data_storage.illegal_behavior=res.data.data.illegal_behavior;
        hearing_notice_data_storage.tir_person=res.data.data.tir_person;
        hearing_notice_data_storage.violate_law=res.data.data.violate_law;
        hearing_notice_data_storage.penalty_decision=res.data.data.penalty_decision;
        hearing_notice_data_storage.punish_basis=res.data.data.punish_basis;
        hearing_notice_data_storage.bureau_address=res.data.data.bureau_address;
        hearing_notice_data_storage.postal_code=res.data.data.postal_code;
        hearing_notice_data_storage.telephone_number=res.data.data.telephone_number;
        hearing_notice_data_storage.undertaker1_name=res.data.data.undertaker1_name;
        hearing_notice_data_storage.undertaker2_name=res.data.data.undertaker2_name;
        hearing_notice_data_storage.staff_license_no1=res.data.data.staff_license_no1;
        hearing_notice_data_storage.staff_license_no2=res.data.data.staff_license_no2;
        hearing_notice_data_storage.year=res.data.data.year;
        hearing_notice_data_storage.month=res.data.data.month;
        hearing_notice_data_storage.day=res.data.data.day;
        hearing_notice_data_storage.year1=res.data.data.year1;
        hearing_notice_data_storage.month1=res.data.data.month1;
        hearing_notice_data_storage.day1=res.data.data.day1;
        hearing_notice_data_storage.case_number=res.data.data.case_number;

    })
}

const get_hearing_notice_data_storage=(row:any)=>{
    hearing_notice_data(row.case_id).then(res=>{
        hearing_notice_data_storage.illegal_behavior=res.data.data.illegal_behavior;
        hearing_notice_data_storage.tir_person=res.data.data.tir_person;
        hearing_notice_data_storage.violate_law=res.data.data.violate_law;
        hearing_notice_data_storage.penalty_decision=res.data.data.penalty_decision;
        hearing_notice_data_storage.punish_basis=res.data.data.punish_basis;
    })
}

//听证告知书打印暂存数据
const hearing_notice_print_data=reactive({
    illegal_behavior:'',
    tir_person:'',
    violate_law:'',
    penalty_decision:'',
    undertaker1:'',
    undertaker2:'',
    hearing_time:'',
    hearing_notice_content:'',
    bureau_address:'',
    postal_code:'',
    telephone_number:''
})


//听证告知书送达文书暂存记录
const hearing_arrive_document_data=reactive({
    arrive_document_name:'听证告知书',
    addressee:'',//受送达人
    arrive_number:'',
    arrive_place:'',//送达地点
    service_mode:'直接送达',//送达方式
    receipt_signature:'',
    receipt_time:'',//签收时间
    subsitute_reason:'',
    witness_signature:'',
    arrive_person1:'',
    arrive_person2:'',//送达人
    arrive_time:'',//送达时间
    remarks:'',//备注
    year:'',
    case_number:'',
    year1:'',
    month1:'',
    day1:'',
    hour1:'',
    min1:'',
    year2:'',
    month2:'',
    day2:'',
    hour2:'',
    min2:'',
    staff_name1:'',
    staff_license_no1:'',
    staff_name2:'',
    staff_license_no2:'',
})


const get_hearing_arrive_document_data=(row:any)=>{
    hearing_arrive_document(row.case_id).then(res=>{
        hearing_arrive_document_data.arrive_number=res.data.data.arrive_number;
        hearing_arrive_document_data.addressee=res.data.data.addressee;
    })
}

//送达文书填写
const hearing_arrive_document_tabel=(row:any)=>{

    create_case.case_id=row.case_id;
    get_hearing_arrive_document_data(row);

    Hearing_arrive_document_Visible.value=true;
}

const hearing_notice_table=(row:any)=>{
    create_case.case_id=row.case_id;
    get_hearing_notice_data_storage(row);
    Hearing_notice_Visible.value=true;
}

const hearing_notice_content_table=(row:any)=>{
    Hearing_notice_content_Visible.value=true;
}

const certain_hearing_notice=()=>{
    if(hearing_notice_data_storage.hearing_time.length==0){
        alert("请输入听证时间")
    }else if(hearing_notice_data_storage.undertaker1.length==0){
        alert("请选择承办人")
    }else if(hearing_notice_data_storage.undertaker2.length==0){
        alert("请选择承办人")
    }else{
        create_case.tcs_note = "听证告知书已完成"
        fetchData_hearing_notice_Confirm(
            create_case.case_id,
            hearing_notice_data_storage.illegal_behavior,
            hearing_notice_data_storage.tir_person,
            hearing_notice_data_storage.violate_law,
            hearing_notice_data_storage.penalty_decision,
            hearing_notice_data_storage.punish_basis,
            hearing_notice_data_storage.undertaker1,
            hearing_notice_data_storage.undertaker2,
            hearing_notice_data_storage.hearing_time,
            hearing_notice_data_storage.bureau_address,
            hearing_notice_data_storage.postal_code,
            hearing_notice_data_storage.telephone_number
        ).then(res=>{
            if (res.data.message === "success"){
                getData()
                fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
                    if (res.data.message === "success"){
                        ElMessage.success('听证告知书已完成');
                        getData();
                        Hearing_notice_Visible.value = false;
                    }else {
                        ElMessageBox.confirm('状态更新失败', '提示', {
                            type: 'warning'
                        })
                    }
                })
            }else{
                ElMessageBox.confirm('确认失败', '提示', {
                    type: 'warning'
                })
            }
        })
    }


}


const certain_arrive_document=()=>{
    if(hearing_arrive_document_data.receipt_time.length==0){
        alert("请选择签收日期");
    }else if(hearing_arrive_document_data.arrive_time.length==0){
        alert("请选择送达日期");
    }else if(hearing_arrive_document_data.arrive_place.length==0){
        alert("请输入送达地点")
    }else if(hearing_arrive_document_data.addressee.length==0){
        alert("请输入受送达人")
    }else if(hearing_arrive_document_data.arrive_person1.length==0){
        alert("请选择送达人")
    }else if(hearing_arrive_document_data.arrive_person2.length==0){
        alert("请选择送达人")
    }else{
        create_case.tcs_note="听证已完成"
        fetchData_arrive_document_Confirm(
            create_case.case_id,
            hearing_arrive_document_data.arrive_document_name,
            hearing_arrive_document_data.addressee,
            hearing_arrive_document_data.arrive_number,
            hearing_arrive_document_data.arrive_place,
            hearing_arrive_document_data.service_mode,
            hearing_arrive_document_data.receipt_signature,
            hearing_arrive_document_data.receipt_time,
            hearing_arrive_document_data.subsitute_reason,
            hearing_arrive_document_data.witness_signature,
            hearing_arrive_document_data.arrive_person1,
            hearing_arrive_document_data.arrive_person2,
            hearing_arrive_document_data.arrive_time,
            hearing_arrive_document_data.remarks
        ).then(res=>{
            if (res.data.message === "success") {
                getData();
                fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
                    if (res.data.message === "success"){
                        ElMessage.success('听证已完成');
                        getData();
                        Hearing_arrive_document_Visible.value=false;
                    }else {
                        ElMessageBox.confirm('状态更新失败', '提示', {
                            type: 'warning'
                        })
                    }
                })
            }else{
                ElMessageBox.confirm('确认失败', '提示', {
                    type: 'warning'
                })
            }
        })
    }

}

const hearing_arrive_document_browse=(row:any)=>{
    get_hearing_arrive_document_browse(row);
    View_Hearing_arrive_document_Visible.value=true;

}


//获取送回达证信息
const get_hearing_arrive_document_browse=(row:any)=>{
    create_case.case_id = row.case_id;
    hearing_arrive_document_print_data(create_case.case_id).then(res=>{
        hearing_arrive_document_data.year=res.data.data.year,
        hearing_arrive_document_data.case_number=res.data.data.case_number,
        hearing_arrive_document_data.arrive_document_name=res.data.data.arrive_document_name,
        hearing_arrive_document_data.arrive_number=res.data.data.arrive_number,
        hearing_arrive_document_data.addressee=res.data.data.addressee,
        hearing_arrive_document_data.arrive_place=res.data.data.arrive_place,
        hearing_arrive_document_data.service_mode=res.data.data.service_mode,
        hearing_arrive_document_data.receipt_signature=res.data.data.receipt_signature,
        hearing_arrive_document_data.year1=res.data.data.year1,
        hearing_arrive_document_data.month1=res.data.data.month1,
        hearing_arrive_document_data.day1=res.data.data.day1,
        hearing_arrive_document_data.hour1=res.data.data.hour1,
        hearing_arrive_document_data.min1=res.data.data.min1,
        hearing_arrive_document_data.year2=res.data.data.year2,
        hearing_arrive_document_data.month2=res.data.data.month2,
        hearing_arrive_document_data.day2=res.data.data.day2,
        hearing_arrive_document_data.hour2=res.data.data.hour2,
        hearing_arrive_document_data.min2=res.data.data.min2,
        hearing_arrive_document_data.subsitute_reason=res.data.data.subsitute_reason,
        hearing_arrive_document_data.witness_signature=res.data.data.witness_signature,
        hearing_arrive_document_data.staff_name1=res.data.data.staff_name1,
        hearing_arrive_document_data.staff_license_no1=res.data.data.staff_license_no1,
        hearing_arrive_document_data.staff_name2=res.data.data.staff_name2,
        hearing_arrive_document_data.staff_license_no2=res.data.data.staff_license_no2,
        hearing_arrive_document_data.remarks=res.data.data.remarks
    })
}

//获取询问人
interface interrogator_data{
    staff_id:number,
    staff_name:string
}
//获取询问者选择框
const interrogator_Data=ref<interrogator_data[]>([]);
const get_interrogator_clause_opinion=(staff_id:number,staff_name:string='')=>{
    fetchData_interrogator_clause(staff_id,staff_name).then(res=>{
        interrogator_Data.value=res.data.data
    })
}
get_interrogator_clause_opinion()




const hearing_arrive_document_print=()=>{
    hearing_arrive_document_print_data(create_case.case_id).then(res=>{
        export_word_13(
            res.data.data.year,
            res.data.data.case_number,
            res.data.data.arrive_document_name,
            res.data.data.arrive_number,
            res.data.data.addressee,
            res.data.data.arrive_place,
            res.data.data.service_mode,
            res.data.data.receipt_signature,
            res.data.data.year1,
            res.data.data.month1,
            res.data.data.day1,
            res.data.data.hour1,
            res.data.data.min1,
            res.data.data.year2,
            res.data.data.month2,
            res.data.data.day2,
            res.data.data.hour2,
            res.data.data.min2,
            res.data.data.subsitute_reason,
            res.data.data.witness_signature,
            res.data.data.staff_name1,
            res.data.data.staff_license_no1,
            res.data.data.staff_name2,
            res.data.data.staff_license_no2,
            res.data.data.remarks
        )
    })
}

const create_hearing_notice_word=()=>{
    hearing_notice_browse_data(create_case.case_id).then(res=>{
        export_word_12(
        res.data.data.illegal_behavior,
        res.data.data.tir_person,
        res.data.data.violate_law,
        res.data.data.penalty_decision,
        res.data.data.bureau_address,
        res.data.data.postal_code,
        res.data.data.telephone_number,
        res.data.data.undertaker1_name,
        res.data.data.undertaker2_name,
        res.data.data.staff_license_no1,
        res.data.data.staff_license_no2,
        res.data.data.year,
        res.data.data.month,
        res.data.data.day,
        res.data.data.year1,
        res.data.data.month1,
        res.data.data.day1,
        res.data.data.case_number
        )
    })
}


// 表格编辑时弹窗和保存
const editVisible = ref(false);
let price_data = reactive({
    evi_id:0,
    case_source:'',
    case_number:'',
    archive_person:'',
    case_update_time:'',
    case_type:'',
    case_remark:'',
    mer_id:0,
    tcs_note:'',
    cs_note:'',
    case_id:0,
    evi_number:0,//数量(条)
    ciga_variety:'',//品种
    barcode:'',//条形码
    ciga_model:'',//规格型号
    ciga_price:0,//单价
    inkjet:'',
    date_of_filing:'',
    date_of_closing:'',
    date_of_archive:'',//立案日期
    year:'',
    month:'',
    day:'',
    evi_id_number:'',

})
let idx: number = -1;
const priceEdit= (index: number, row: any) =>{
    price_data.case_id=row.case_id;
    price_data.evi_id=row.evi_id;
    price_data.case_number=row.case_number;
    price_data.case_source=row.case_source;//案件性质
    price_data.case_update_time=row.case_update_time;
    price_data.date_of_archive=row.date_of_archive;
    price_data.case_type=row.case_type;
    price_data.ciga_variety=row.ciga_variety;
    price_data.barcode=row.barcode;
    price_data.ciga_model=row.ciga_model;
    price_data.ciga_price=row.ciga_price;
    price_data.evi_number=row.evi_number;
    price_data.year=row.year;
    price_data.month=row.month;
    price_data.day=row.day;
    price_data.evi_id_number=row.evi_id_number;
    editVisible.value=true;
};

const saveEdit = () => {
    editVisible.value = false;
    fetchData_price_Edit(
        price_data.evi_id,
        price_data.case_id,
        price_data.ciga_price,
        price_data.evi_number,
    ).then(res =>{
        if (res.data.message === "success"){
            getData()
            ElMessage.success('修改成功');
        }else {
            ElMessageBox.confirm('修改失败', '提示', {
                type: 'warning'
            })
        }});
};



interface Evidence_ciga_data {
    case_id:number,
    evi_number:number,
    ciga_variety:string,
    barcode:string,
    ciga_model:string,
    ciga_price:number,
    inkjet:string,
    evi_id_number:string,

}
const evidence_ciga_Data= ref<Evidence_ciga_data[]>([]);
// 暂存先行保存批准书数据
const case_evi_data = reactive({
    date_of_filing:'',
    year:'',
    month:'',
    day:'',
    evi_id_number:'',
    evi_id_number1:'',
    illegal_behavior:'',
    tlc_id:'',
    mer_person:'',
    mer_id:'',
    tce_type_number:'',
    tce_number:'',
    tce_address:'',
    user_id_1:'',
    user_id_2:'',
    user_name_1:'',
    user_name_2:'',
})
//核价表按钮
const price_tabel = (row:any) =>{
    get_review_price_Data(row.case_id);
    //get_case_evidenct_data(row.case_id);
    create_case.case_id = row.case_id;
    Price_list_Visible.value = true;
}



const certain_price=()=>{
    create_case.tcs_note = "涉案烟草价品核案表完成"
    fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
        if (res.data.message === "success"){
            ElMessage.success('涉案烟草价品核案表完成');
            getData();
            Price_list_Visible.value = false;
        }else {
            ElMessageBox.confirm('状态更新失败', '提示', {
                type: 'warning'
            })
        }
    })
}

const hearing_notice_browse=(row:any)=>{
    create_case.case_id=row.case_id;
    get_hearing_notice_browse_data(row);
    Hearing_notice_Borwse_Visible.value=true;
}



const img_form_data = reactive({
    case_number: '',
    name:'',
    content:'',
    remark:'',
    img:'',
});
const img = [];
const handleChange = (file) =>{
    img.push(file);
}
const handleRemove = (file) =>{
    img.forEach(function (item,index,arr){
        if (item.name == file.name){
            img.splice(index,1)
        }
    })
}


const advice_note_views = (row:any) =>{
    img_form_data.case_number = row.case_number;
    fetchData_s_mongodb_evidence_Views(row.case_number,"证据先行保存通知书").then(res => {
        img_form_data.img=res.data.data[0].img
        console.log(img_form_data.img)

    });
    Advice_note_Views_Visible.value=true;
}


const query = reactive({
    case_id:0,
    case_source:'',
    case_type:'',
    tcs_note_id:'',
    case_number:'',
    cs_note_id:'',//送达文书状态
    pageIndex: 1,
    pageSize: 10
});
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person:string='',case_id:number,case_source:string='',case_type:string='',case_number:string='',tcs_note_id:string='',name:string='') => {
    fetchData_case(archive_person,case_id,case_source,case_type,case_number,tcs_note_id,name).then(res => {
        tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) =>(
            i.tcs_note_id =="无证经营公示已完成" ||
            i.tcs_note_id=="案件处理审批已开始"||
            i.tcs_note_id=="听证已开始"||
            i.tcs_note_id=="集体讨论已完成"||
            i.tcs_note_id=="听证告知书已完成"||
            i.tcs_note_id=="听证已完成"||
            i.tcs_note_id=="案件处理审批已完成"||
            i.tcs_note_id=="行政处罚事先告知书确认完成"||
            i.tcs_note_id=="行政处罚事先告知书已完成"||
            i.tcs_note_id=="行政处罚决定书确认完成"||
            i.tcs_note_id=="行政处罚决定书已完成"||
            i.tcs_note_id=="行政罚款收据上传完成"||
            i.tcs_note_id=="行政罚款收据已完成"||
            i.tcs_note_id=="结案报告表已完成"||
            i.tcs_note_id=="已完成"

        )  )
      tableList.value = [];
      pageTotal.value = tableData.value.length || 50;
      // 根据页码确定下标位置
      const index: number = query.pageIndex * query.pageSize - query.pageSize;
      for (let i = index; i < index + query.pageSize; i++) {
        // 防止数组下标越界
        if (i <= tableData.value.length - 1) {
          tableList.value.push(tableData.value[i])
        } else {
          // 越界就不再循环
          break;
        }
      }
    });
};
getData('','','','','','',localStorage.getItem('ms_username'));
// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
    getData('','',case_source,case_type,case_number,tcs_note_id,name);
};
// 分页导航
const handlePageChange = (val: number) => {
  query.pageIndex = val;
    getData('','','','','','',localStorage.getItem('ms_username'));
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}
.handle-box button{
    background-color: #00a854;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}

:deep(.avatar){
    width: 100px;
    height: 100px;
}
.blue {
    color: rgba(0, 118, 252, 0.79);
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
.dialog-footer button{
    background-color: #00a854;
    color:white;
}
/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/

/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
